package com.android.base_network.exception

import com.android.base_network.data.IBaseResponse

open class ResponseThrowable : Exception {
    private var code: Int
    private var errMsg: String

    constructor(error: ERROR, e: Throwable? = null) : super(e) {
        code = error.code
        errMsg = error.err
    }

    constructor(code: Int, msg: String, e: Throwable? = null) : super(e) {
        this.code = code
        this.errMsg = msg
    }

    constructor(base: IBaseResponse<*>, e: Throwable? = null) : super(e) {
        this.code = base.code()
        this.errMsg = base.message()
    }

    // 获取状态码
    fun getCode() = code

    // 获取错误信息
    fun getErrMsg() = errMsg
}

